package com.unistrong.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.unistrong.annotation.LoginRequired;
import com.unistrong.model.entity.DxhdAblx;
import com.unistrong.service.intf.DxhdAblxService;
import com.unistrong.util.Datas;
import com.unistrong.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import springfox.documentation.annotations.ApiIgnore;

import java.util.Collection;
import java.util.Map;

/**
 * <p>
 * 安保路线信息表 前端控制器
 * </p>
 *
 * @author menu
 * @since 2021-07-19
 */
@Api(tags = {"DxhdAblxController"},value ="安保路线信息",description = "接口描述")
@RestController
@RequestMapping("/dxhd-ablx")
public class DxhdAblxController {

    @Autowired
    private DxhdAblxService dxhdAblxService;

    @LoginRequired
    @ApiOperation(value = "分页查询")
    @GetMapping("test")
    public R test(@ApiIgnore @RequestParam Map<String, Object> params){

        return R.ok().put("data","OK");

    }

    @ApiOperation(value = "分页查询")
    @RequestMapping("selectPage")
    public R selectPage(@ApiIgnore @RequestBody Datas<DxhdAblx> datas){
        Page<DxhdAblx> page = new Page<>(datas.getCurrent(),datas.getSize());
        DxhdAblx entity = datas.getEntity();
        QueryWrapper<DxhdAblx> wrapper =new QueryWrapper<>();
        wrapper.eq("JWLX_JWLXBH",entity.getJwlxJwlxbh());
        wrapper.like("UTU",entity.getUtu());
        IPage<DxhdAblx> pageVo = dxhdAblxService.page(page,wrapper);
        return R.ok().put("data",pageVo);

    }


    @ApiOperation(value = "根据id查询记录")
    @RequestMapping("getById")
    public R getById(@RequestParam String Id){
        DxhdAblx result = dxhdAblxService.getById(Id);
        return R.ok().put("data",result);

    }

    @ApiOperation(value = "保存单条记录")
    @PostMapping("save")
    public R save(@RequestBody DxhdAblx entit){
        Boolean result = dxhdAblxService.save(entit);
        return R.ok().put("data",result);
    }


    @ApiOperation(value = "批量保存")
    @RequestMapping("saveBatch")
    public R saveBatch(@RequestBody Collection<DxhdAblx> entityList){
        Boolean result = dxhdAblxService.saveBatch(entityList);
        return R.ok().put("data",result);

    }


    @ApiOperation(value = "根据 ID 选择修改")
    @RequestMapping("updateById")
    public R updateById(@RequestBody DxhdAblx entit){
        Boolean result = dxhdAblxService.updateById(entit);
        return R.ok().put("data",result);

    }


    @ApiOperation(value = "根据ID 批量更新")
    @RequestMapping("updateBatchById")
    public R updateBatchById(@RequestBody Collection<DxhdAblx> entityList){
        Boolean result = dxhdAblxService.updateBatchById(entityList);
        return R.ok().put("data",result);

    }


    @ApiOperation(value = "根据 ID 删除")
    @RequestMapping("removeById")
    public R removeById(@RequestParam String Id){
        Boolean result = dxhdAblxService.removeById(Id);
        return R.ok().put("data",result);

    }


    @ApiOperation(value = "删除（根据ID 批量删除）")
    @RequestMapping("removeByIds")
    public R removeByIds(@RequestBody Collection<String> Ids){
        Boolean result = dxhdAblxService.removeByIds(Ids);
        return R.ok().put("data",result);
    }
}

